/**
 * 
 */
package ru.etu.game;

import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;


/**
 * @author Alucard
 * @author Neko
 * класс Игрок, реагирует на нажатие клавиш.
 */
public class Player extends Tank {
	
	/**
	 * @author Alucard
	 * @author Neko
	 * Обработчик движения Player'a
	 */
	public  class KeyInput extends KeyAdapter{
		@Override
		public void keyPressed(KeyEvent e) {
			switch( e.getKeyCode()){
				case KeyEvent.VK_LEFT: 	
					setNewPosition(getPoint().minus(new Point(Engine.MINIMAL_MOVE,0,0)));
					setFront(Direction.LEFT);
					break;
				case KeyEvent.VK_UP: 	
					setNewPosition(getPoint().minus(new Point(0,Engine.MINIMAL_MOVE,0)));
					setFront(Direction.UP);
					break;
				case KeyEvent.VK_RIGHT:	
					setNewPosition(getPoint().plus(new Point(Engine.MINIMAL_MOVE,0,0)));
					setFront(Direction.RIGHT);
					break;
				case KeyEvent.VK_DOWN:	
					setNewPosition(getPoint().plus(new Point(0,Engine.MINIMAL_MOVE,0)));
					setFront(Direction.DOWN);
					break;
				case KeyEvent.VK_SPACE:	
					fire();							
					break;
			}
		}			
	}
	/**
	 * @return обработчик
	 */
	public KeyInput getListener(){
		return new KeyInput();	
	}	
}
